package util 
{
	import assets.UIAsset;
	import vo.LocationVO;
	import vo.MapObjectVO;
	import vo.MOConfigVO;
	/**
	 * ...
	 * @author lgyu
	 */
	public class MapDataUtil 
	{
		
		public function MapDataUtil() 
		{
			
		}
		
		public static function getMapGrid(mo:MapObjectVO, isStandMO:Boolean = true ):Object {
			//trace("mo:" + mo)
			var osx:int = mo.positionX
			var osy:int = mo.positionY
			var moc:MOConfigVO = UIAsset.getConfigVoByTypeId(mo.typeId);
			//trace("moc:" + mo.typeId)
			var mapData:Object = {}
			var sd:Array = moc.mask.split("")
			var xs:int = int(sd[0])
			var ys:int = int(sd[1])
			var xe:int = int(sd[2])
			var ye:int = int(sd[3])
			//trace(sd.length+":"+sd)
			for (var i:int = xs; i <= xe; i++ ) {
				for (var j:int = ys; j <= ye; j++ ) {
					var name:String = isStandMO ? "tile_" + (i + osx) + "_" + (j+osy):"tile_" + i  + "_" + j
					mapData[name] = isStandMO ? 1: 0;
					
				}
			}
			return mapData
		}
		
		static public function showData(mapData:Object):void 
		{
			for ( var i:String in mapData) {
				//trace(i+":"+mapData[i])
			}
		}
		
		public static function getArrByMask(mask:String):Object {
			
			var sd:Array = mask.split("")
			var start:LocationVO = new LocationVO
			var end:LocationVO = new LocationVO
			start.x = sd[0], start.y = sd[1];
			end.x = sd[2], end.y = sd[3];
			return {start:start, end:end}
		}
		
		
	}

}